﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BonsaiScrum.Core.Domain
{
    public class ScrumMaster : IRole, IEquatable<ScrumMaster>
    {
        public ScrumMaster() { }

        public ScrumMaster(User actor)
        {
            if (actor == null)
                throw new ArgumentNullException("actor");

            Actor = actor;
        }

        public PermissionLevel PermissionLevel
        {
            get { return PermissionLevel.ScrumMaster; }
        }

        public User Actor { get; private set; }

        internal void CreateStoryForProject(Project project, string storyDescription)
        {
            
            project.AddNewStory(this, storyDescription);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (!obj.GetType().Equals(this.GetType())) return false;
            return Equals((ScrumMaster)obj);
        }

        public bool Equals(ScrumMaster other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.Actor.Equals(Actor);
        }
    }
}
